import * as YvanUI from 'yvan-ui-wotu'
import * as CustomService from '@server/example/CustomService'

interface Ref {
    t1: YvanUI.Text,
    t2: YvanUI.Text
}

const React = YvanUI.React
const _ = YvanUI.lodash

export default class Simple2 extends YvanUI.Scope<void, Ref> {

    query = this.$$({
        f1: '',
        f2: ''
    })

    onRender() {
        window['biz'] = this
    }

    vjson = {
        title: '极简示例-table',
        items: [
            {
                view: 'table',
                idField: 'customer_id',
                // 是否分页
                pagination: true,
                // 分页数
                pageSize: 20,
                // 强制每次分页选择请求总数
                // requiredCount: true,
                // 默认显示第二页
                defaultPage: 2,
                // 勾选
                selection: true,

                height: 500,
                // hidRowNumber: true,
                title: '客户',
                // clickRowStyle: 'clickRowStyle',
                columns: [
                    {title: '客户编号', dataIndex: 'customer_code', sorter: true},
                    {title: '客户名称', dataIndex: 'customer_name'},
                    {title: '客户类型', dataIndex: 'industry_class'},
                    {title: '客户类别', dataIndex: 'customer_type'},
                    {title: '结算方', dataIndex: 'accounts'},
                    {title: '承运方', dataIndex: 'shipper'},
                    {title: '邮编', dataIndex: 'zip'},
                    {title: '联系人', dataIndex: 'contact'},
                    {title: '电话', dataIndex: 'telephone'},
                    {title: '是否启用', dataIndex: 'is_enable',
                        formatter: YvanUI.dict['is_enable']
                    },
                    {title: '备注', dataIndex: 'remark'},
                    {title: '创建者', dataIndex: 'create_by'},
                    {
                        title: '建立时间', dataIndex: 'create_at',
                        formatter: "fmtDateNoTime",
                        render: (value: any, fmtValue: any, rowData: any, index: number) => {
                            return fmtValue
                        },
                    },
                    {title: '修改者', dataIndex: 'update_by'},
                ],
                dataSource: {
                    func: CustomService.selectAll,
                    params: {
                        field1: () => 'aaa' + this.query.f1,
                        field2: () => 'bbb' + this.query.f2
                    }
                }
            }
        ]
    }
}